package TestExtentd;

import java.util.Scanner;

public class Computer {
    String brand;
    CPU cpu;
    Memory memory;
    HardDisk hardDisk;

    Scanner sc = new Scanner(System.in);
    Computer(String brand, TestExtentd.CPU cpu, TestExtentd.Memory memory, TestExtentd.HardDisk hardDisk){
        this.brand = brand;
        this.cpu = cpu;
        this.memory = memory;
        this.hardDisk = hardDisk;
    }
    void start(){
        int a;
        String c;
        TestExtentd.Memory b;
        System.out.println(brand+"已启动");
        cpu.process();
        memory.store();
        hardDisk.readWrite();
        System.out.println("1<--输出电脑信息");
        System.out.println("2<--更换内存");
        switch(sc.nextInt()){
            case 1:
                showSpec();
                break;
            case 2:
                System.out.println("更换内存品牌");
                c=sc.next();
                System.out.println("更换内存大小");
                a=sc.nextInt();
                b=new TestExtentd.Memory(a,c);
                upgradeMemory(b);
                break;
        }
    }
    void showSpec(){
        System.out.println("CPU模式"+cpu.getModel()+"   "+"CPU速度"+cpu.getSpeed());
        System.out.println("内存厂商:"+memory.getType()+"       "+"内存大小(G):"+memory.getCapacity());
    }
    void upgradeMemory(TestExtentd.Memory memory){
    this.memory=memory;
        System.out.println("内存厂商:"+memory.getType()+"       "+"内存大小(G):"+memory.getCapacity());
    }
}
